-- man_of_steel
-- created by wangy
-- 进入下层恢复属性N%（钢铁之躯）

return {
    apply = function(prop, baseValue)
        return math.modf(baseValue * prop[3] / 1000);
    end,

    -- 进入下层触发触发
    trigger = function(who, prop, arg)
        local attrib = prop[2];
        local value = prop[3];
        local max;

        -- 暂时只有hp和mp

        if attrib == "hp" then
            max = who:getMaxHp();
        elseif attrib == "mp" then
            max = who:getMaxMp();
        end

        if not max or max <= 0 then
            return false;
        end

        -- 千分比恢复
        value = math.modf(max * value / 1000);

        BonusM.doBonus({ 2, attrib, value, }, "prop man_of_steel");

        -- 触发特技发动事件, 先记在玩家身上
        ME.user.dbase:setTemp("speicial_skill_trigger", prop[1]);
        return v;
    end,

    desc = function(prop)
        local row = PropM.getRow(prop[1]);
        local desc = row.desc;
        local attrib = FieldsM.getFieldName(prop[2]);
        if attrib then
            desc = string.gsub(desc, "{0}", attrib);
        end

        -- 根据属性，显示“恢复”或“获得”
        if prop[2] == "money" or prop[2] == "search_point" then
            desc = string.gsub(desc, "{recover}", getLocStr("gain"));
        else
            desc = string.gsub(desc, "{recover}", getLocStr("recover"));
        end

        desc = string.gsub(desc, "{1}", math.modf(prop[3] / 10));

        return desc;
    end,

    record = function(target, prop, path)
        return false;
    end
};